package com.dlengine.boot.web.config;

import com.dlengine.boot.web.converter.jackson.JacksonHttpMessageConverter;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * WebMvcConfig
 *
 * @author chentudong
 * @date 2024/1/15 15:39
 * @since 1.0
 */
@Configuration
@ConditionalOnProperty(prefix = "dlengine.boot.web.http.message.converter", name = "enabled", havingValue = "true")
public class WebMvcConfig extends WebMvcConfigurationSupport {

  private static final Logger LOGGER = LoggerFactory.getLogger(WebMvcConfig.class);

  public WebMvcConfig() {
    LOGGER.info("-- init dlengine.boot.web.http.message.converter.enabled=true");
  }

  @Override
  protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    converters.add(new JacksonHttpMessageConverter());
    super.configureMessageConverters(converters);
  }
}
